const Koa = require('koa');
//Application
const app = new  Koa();
//路由
const router = require('koa-router')();

//配置项
const config = require('./config');
console.log(`redis_hosts: ${config.redis_hosts} redis_port: ${config.redis_port}`);

router.get('/getApi',async (context,next) => {
  context.response.type = 'text/html';
  context.response.body = '<h1>Hello, Get Request!</h1>';
});

router.post('/postApi',async (context,next) => {
  context.response.type = 'text/html';
  context.response.body = '<h1>Hello, Post Request!</h1>';
});

//使用路由
app.use(router.routes());

//开启服务,监听3001端口
app.listen(3001);

console.log(`process.env.NODE_ENV: ${process.env.NODE_ENV}`);
